import {Injectable} from "@angular/core";
import {PreloadingStrategy, Route} from "@angular/router";
import {Observable, of} from "rxjs";

@Injectable()
export class MypreloadService implements PreloadingStrategy {
  constructor() {

  }

  preload(route: Route, load: () => Observable<any>): Observable<any> {
    // if (route.data && route.data["preload"] || location.href.includes("ctr")) {
    //   return load();
    // } else {
    //   return of(null);
    // }

    if (route.data && route.data["preload"]) {
      return load();
    } else {
      return of(null);
    }
  }
}
